* This file replicates the empirical analysis presented in "Threats at Home and Abroad: Interstate War, Civil War, and Alliance Formation*"
* Jessica Edry, Jesse Johnson, and Brett Ashley Leeds
* 12/5/20

set more off
cd "C:\Users\jcjo228\Dropbox\Alliances & Civil War Paper\Replication Files\EdryJohnson&LeedsIOrep\"
use "EdryJohnson&LeedsIOrep.dta", clear
	
* Table 1: 

	 logit form_defense threat small large majpow contig defense consul neunon, robust 
	 logit form_consul threat small large majpow contig defense consul neunon, robust 
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon, robust

* Substantive Effects and First Differences

	* Model 1: 
	
	estsimp logit form_defense threat small large majpow contig defense consul neunon, robust
	
	setx mean  
	setx threat .31
	simqi, prval(1) 

	setx mean 
	setx threat .43
	simqi, prval(1) 
	
	drop b1-b9
	
	* Model 2:
	
	estsimp logit form_consul threat small large majpow contig defense consul neunon, robust 

	setx mean  
	setx small 0 large 0
	simqi, prval(1) 

	setx small 1 large 0
	simqi, prval(1) 
	
	setx small 0 large 1
	simqi, prval(1) 
	
	setx small 0 large 0
	simqi, fd(prval(1)) changex(small 0 1)
	
	setx small 0 large 0
	simqi, fd(prval(1)) changex(large 0 1)

	drop b1-b9

	estsimp logit form_consul threat noexcl large majpow contig defense consul neunon, robust 

	setx mean
	setx noexcl 0 large 1
	simqi, fd(prval(1)) changex(large 0 1)
	
	drop b1-b9

	* Model 3:
	
	estsimp logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon, robust

	setx mean  
	setx extek 0 exteks 0 exnotek 0
	simqi, prval(1) 

	setx extek 0 exteks 0 exnotek 1
	simqi, prval(1) 
	
	setx extek 0 exteks 1 exnotek 0
	simqi, prval(1)  
	
	setx extek 1 exteks 0 exnotek 0
	simqi, prval(1) 

	setx extek 0 exteks 0 exnotek 0
	simqi, fd(prval(1)) changex(extek 0 1)

	drop b1-b10

	estsimp logit form_neunon threat noexcl exteks extek majpow contig defense consul neunon, robust
	
	setx mean
	setx extek 0 exteks 0 noexcl 0
	simqi, fd(prval(1)) changex(extek 0 1)

	drop b1-b10
	
	estsimp logit form_neunon threat noexcl exnotek extek majpow contig defense consul neunon, robust
	
	setx mean
	setx extek 0 noexcl 0 exnotek 0
	simqi, fd(prval(1)) changex(extek 0 1)

	drop b1-b10
	
*******************************************************************************

* Appendix

* Table A1:

	 logit form_defense threat small large majpow contig defense consul neunon ongoing, robust 
	 logit form_consul threat small large majpow contig defense consul neunon ongoing, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon ongoing, robust
	
* Table A2: 

	 logit form_defense threat small large majpow contig defense consul neunon lgdpcapl, robust 
	 logit form_consul threat small large majpow contig defense consul neunon lgdpcapl, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon lgdpcapl, robust

* Table A3: 

	 logit form_defense threat small large majpow contig defense consul neunon oilpcl, robust 
	 logit form_consul threat small large majpow contig defense consul neunon oilpcl, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon oilpcl, robust

* Table A4: 

	 logit form_defense threat small large majpow contig defense consul neunon lpop, robust 
	 logit form_consul threat small large majpow contig defense consul neunon lpop, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon lpop, robust

* Table A5: 

	 logit form_defense threat small large majpow contig defense consul neunon mtnest, robust 
	 logit form_consul threat small large majpow contig defense consul neunon mtnest, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon mtnest, robust

* Table A6: 

	 logit form_defense threat small large majpow contig defense consul neunon warhist, robust 
	 logit form_consul threat small large majpow contig defense consul neunon warhist, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon warhist, robust

* Table A7: 

	 logit form_defense threat small large majpow contig defense consul neunon democ, robust 
	 logit form_consul threat small large majpow contig defense consul neunon democ, robust
	 logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon democ, robust
	
* Table A8: 

	 logit form_puredefense threat small large majpow contig defense consul neunon, robust 
	 logit form_pureconsul threat small large majpow contig defense consul neunon, robust
	 logit form_pureneunon threat exnotek exteks extek majpow contig defense consul neunon, robust

* Table A9:

	logit form_defense threat small large majpow contig defense consul neunon if relevant==1, robust 
	logit form_consul threat small large majpow contig defense consul neunon if relevant==1, robust
	logit form_neunon threat exnotek exteks extek majpow contig defense consul neunon if relevant==1, robust
	
* Table A10:

	logit form_consul threat small_pop large_pop majpow contig defense consul neunon, robust
	
* Table A11:
	
	logit form_defense threat small_mean large_mean majpow contig defense consul neunon, robust 
	logit form_consul threat small_mean large_mean majpow contig defense consul neunon, robust
	logit form_neunon threat exnotek exteks_mean extek_mean majpow contig defense consul neunon, robust
	
* Table A12:
	
	logit form_defense threat small_40 large_40 majpow contig defense consul neunon, robust 
	logit form_consul threat small_40 large_40 majpow contig defense consul neunon, robust
	logit form_neunon threat exnotek exteks_40 extek_40 majpow contig defense consul neunon, robust	
	
* Table A13:
	
	logit form_defense threat small_60 large_60 majpow contig defense consul neunon, robust 
	logit form_consul threat small_60 large_60 majpow contig defense consul neunon, robust
	logit form_neunon threat exnotek exteks_60 extek_60 majpow contig defense consul neunon, robust	

* Table A14
	
	logit form_consul threat small_sum large_sum majpow contig defense consul neunon, robust
	
* Table A15:

	logit form_consul ex_low ex_high threat majpow contig defense consul neunon, robust

* Table A16:

	mvprobit (form_defense=threat small large majpow contig defense consul neunon) (form_consul=threat small large majpow contig defense consul neunon) (form_neunon = threat exnotek exteks extek majpow contig defense consul neunon), robust
